#pragma once

#include "Part.h"
#include "Common/RunBusinessDefine.h"

class RunBusinessPart : public Part
{
public:
	RunBusinessPart();
	virtual ~RunBusinessPart();

public:
	virtual bool		Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	virtual bool		UnInit();
	virtual bool		OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	virtual void		OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void		OnTimer(uint32_t nTimerID){}
	virtual bool		SynOnLogin();
	virtual void		OnChangeLogic();
	virtual bool		SaveDB(CharacterDBInfo& characterDB);

	virtual void		Update(uint64_t tick){}

public: //消息回调接口 
	bool				HandleOpenRunBusinessReq(const char* data, uint32_t len);	
	bool				HandleReceiveRunBusinessReq(const char* data, uint32_t len);
	bool				HandleSubmitRunBusinessReq(const char* data, uint32_t len);
	bool				HandleExchangeRunBusinessReq(const char* data, uint32_t len);

private:
	void				GetBusinessIds(VEC_UINT32& businessIds);
	bool				CanAcceptRunBusiness(uint32_t businessId);
	void				SumbitReward(uint32_t businessId);

public:
	void				InitRunBusiness();

private:
};
